#include <bits/stdc++.h>
// 2025/02/19
// tag: 
// Author: Forever
using namespace std;

using int64 = int64_t;

int input[10001];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    for (int i = 1; i <= t; i++) 
        cin >> input[i];
    for (int i = 1; i <= t; i++) {
        while (input[i] >= 0) {
            if (input[i] % 11 == 0)
            {
                cout << "YES" << endl;
                break;
            }
            input[i] -= 111;
        }
        if (input[i] < 0) cout << "NO" << endl;
    }
    return 0;
}